home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nejlepší hry
/
Nejlepsi hry.iso
/
hry
/
sea of chaos
/
sea_install.msi
/
_15C39AAA7726369D39812BD40F01CF6A
/
_F32E1E6DF7554D91870A732B6D21417A
< prev
next >
Wrap
Text File
|
2005-03-02
|
2KB
|
70 lines
//water vertex shader:
//adjusts alpha based on angle between surface normal and eye
//1 directional light also applied
//also does environmental reflection off water (env map should be fixed relative to axises)
//Luke Lenhart
//(C)2004-2005 Digipen Institute of Technology
//world,view,projection transform
float4x4 matWorld;
float4x4 matWorldViewProj;
//camera position in world space
float4 cameraPos;
//directional light (assumed to be the sun)
float4 lgtDirection;
//shader input
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Normal : NORMAL;
float4 Clr: COLOR0;
};
//shader output
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float2 Tex0 : TEXCOORD0;
float3 Tex1 : TEXCOORD1;
//float FogClr : TEXCOORD2;
};
//shader code
VS_OUTPUT VShader(VS_INPUT In)
{
VS_OUTPUT Out;
//tex coord generated from position
Out.Tex0=In.Pos;
//out position
Out.Pos=mul(matWorldViewProj,In.Pos);
//calc directional light color
Out.Color=dot(In.Normal,lgtDirection)*In.Clr;
//calc alpha based dot between vertex normal and vector from vertex to camera
//taken to a high power to spread translucent range over more of the angle range
//done in world space
float3 vecEyeToVertex=normalize(cameraPos-In.Pos);
float alpha=pow(1.0f-dot(vecEyeToVertex,In.Normal), 15.0f);
Out.Color+=alpha*float4(0.2f,0.2f,0.2f,0.0f);
Out.Color.a=(0.6f+alpha)*In.Clr.a;
//calc env reflection vector
//done in world space
float3 tranNorm=In.Normal.xyz;
Out.Tex1=reflect(-vecEyeToVertex,tranNorm);
//calc fog color
//Out.FogClr=saturate(log(distance(cameraPos.xyz,In.Pos.xyz))*0.08f - 0.1f);
//spit out the results
return Out;
}